"""循环的练习
"""

# 求1到100 之间的偶数总和
i = 1
result = 0

while i <= 100:
    if i % 2 == 0:
        result += i
    i += 1

# print("总和等于:%d" % result)


# 用*号打一个矩形
a = 10

while a > 0:
    x = 1
    while x <= 10:
        print("*", end="")
        x += 1
    print("")
    a -= 1
print("over")

del x

# while 的循环嵌套
# 注意缩进

# 打印乘法表
x = 1
while x <= 9:
    y = 1
    while y <= x:
        print("%d * %d = %d\t" % (y, x, x*y), end="")
        y += 1
    print("")
    x += 1
print("over")


# 打印倒的等边三角形
# d是边上的星星个数 星星之间用空格链接
d = 5
d_temp = d
while d >= 0:
    blank = " " * (d_temp - d)
    print(blank, end="")
    for i in range(d):
        print("*", end="")
        print(" ", end="")
    print("")
    d -= 1
print("over")

